package com.chase.chasecat.service.impl;

import com.chase.chasecat.common.R;
import com.chase.chasecat.dto.AddPetDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chase.chasecat.dao.PetDao;
import com.chase.chasecat.entity.PetEntity;
import com.chase.chasecat.service.PetService;

import javax.annotation.Resource;

@Service("petService")
public class PetServiceImpl extends ServiceImpl<PetDao, PetEntity> implements PetService {
    @Resource
    private PetDao petDao;

    @Override
    public R addPet(AddPetDTO addPetDTO) {
        PetEntity petEntity = new PetEntity();
        BeanUtils.copyProperties(addPetDTO,petEntity);
        int num = petDao.insert(petEntity);
        if (num == 1){
            return R.ok("新增成功");
        }
        return R.fail("新增失败");
    }
}